//
//  testViewController.m
//  iphoneApp
//
//  Created by Liyu on 13-1-6.
//  Copyright (c) 2013年 __MyCompanyName__. All rights reserved.
//

#import "testViewController.h"

#import <QuartzCore/QuartzCore.h>

#import "LYTabBar.h"

@interface testViewController ()

@end

@implementation testViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];   
    
    self.wantsFullScreenLayout=YES;
    self.navigationController.navigationBarHidden=YES;
    
    self.view.backgroundColor=[UIColor redColor];
    
    CGRect  screen=[[UIScreen mainScreen] bounds];	
    CGFloat tabBarHeight=44.0f;
    
    LYTabBar * lyTabBar=[[LYTabBar alloc] initWithFrame:CGRectMake(0, screen.size.height-tabBarHeight, screen.size.width, tabBarHeight)];
    
    NSLog(@"height is %f---%f",screen.size.height,(screen.size.height-tabBarHeight));
    
    lyTabBar.delegate=self;
    
    
    UITabBarItem * item1=[[UITabBarItem alloc] initWithTitle:@"下载" image:[UIImage imageNamed:@"22-skull-n-bones.png"] tag:1];
    UITabBarItem * item2=[[UITabBarItem alloc] initWithTitle:@"收藏" image:[UIImage imageNamed:@"23-bird.png"] tag:2];
    NSMutableArray * arr=[NSMutableArray arrayWithObjects:item1,item2, nil];
    
    [item1 release];
    [item2 release];
    
    [lyTabBar setTabBarWithItems:arr];
    
    [self.view addSubview:lyTabBar];
    //[self.view bringSubviewToFront:lyTabBar];
    [lyTabBar release];       
}

-(void)lyTabBar:(LYTabBar *)tabBar didSelectItemIndex:(NSInteger)index
{
   
    if ([UIApplication sharedApplication].statusBarHidden) {
        [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationSlide];
    }
    else {
         [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
    }
     
    
    if (index==1) {
    
    }
}


- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
